package org.openkoala.demo.core.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

/**人员*/
@Entity
@DiscriminatorValue("PERSON")
public class Person extends Party {

    /**null*/
    @Column(name = "AGE")
    private Integer age;

    /**null*/
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "BIRTHDAY")
    private Date birthday;

    Person() {
    }

    /**
     * 取得null
     * @return age null
     */
    public Integer getAge() {
        return age;
    }

    /**
     * 设置null
     * @param age null
     */
    public void setAge(Integer age) {
        this.age = age;
    }

    /**
     * 取得null
     * @return birthday null
     */
    public Date getBirthday() {
        return birthday;
    }

    /**
     * 设置null
     * @param birthday null
     */
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }


    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37).append(this.getAge()).append(this.getBirthday()).toHashCode();
    }

    @Override
    public boolean equals(Object other) {
        if (!(other instanceof Person)) {
            return false;
        }
        Person that = (Person) other;
        return new EqualsBuilder().append(this.getAge(), that.getAge()).append(this.getBirthday(), that.getBirthday()).isEquals();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this).append(this.getAge()).append(this.getBirthday()).build();
    }
}
